home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / CAppendiceSearchResult.as < prev    next >
Text File  |  2007-11-08  |  12KB  |  340 lines

  1. class CAppendiceSearchResult extends mx.core.UIObject
  2. {
  3.    var mPagePrefetch = 16;
  4.    var mFullyPopulatedCallback = "";
  5.    function CAppendiceSearchResult()
  6.    {
  7.       super();
  8.       this.mInitialized = false;
  9.       this.mFullyPopulatedCallback = "";
  10.       this.txt_RisultatiVoci.text = "";
  11.       this.txt_RisultatiContributi.text = "";
  12.       this.txt_RisultatiProspettive.text = "";
  13.       this.doLater(this,"init");
  14.    }
  15.    function init()
  16.    {
  17.       this.mInitialized = true;
  18.       this.mFirstClick = 0;
  19.       this.mDoubleClickInterval = 200;
  20.       this.mCurrentTab = "voci";
  21.       this.mListboxArray = new Array(this.lboxVociSearchResults,this.lboxContributiSearchResults,this.lboxProspettiveSearchResults);
  22.       var _loc3_ = 0;
  23.       while(_loc3_ < this.mListboxArray.length)
  24.       {
  25.          this.mListboxArray[_loc3_].rowHeight = 22;
  26.          this.mListboxArray[_loc3_].addEventListener("change",mx.utils.Delegate.create(this,this.onItemSelected));
  27.          this.mListboxArray[_loc3_].addEventListener("itemRollOver",mx.utils.Delegate.create(this,this.onItemRollOver));
  28.          this.mListboxArray[_loc3_].addEventListener("itemRollOut",mx.utils.Delegate.create(this,this.onItemRollOut));
  29.          this.mListboxArray[_loc3_].hScrollPolicy = "on";
  30.          this.mListboxArray[_loc3_].vScroller.__trackThumb = false;
  31.          this.mListboxArray[_loc3_].setStyle("borderStyle","solid");
  32.          this.mListboxArray[_loc3_].setStyle("borderColor",12566711);
  33.          this.mListboxArray[_loc3_].setStyle("selectionColor",16099163);
  34.          this.mListboxArray[_loc3_].setStyle("rollOverColor",16703406);
  35.          this.mListboxArray[_loc3_].setStyle("textRollOverColor",0);
  36.          this.mListboxArray[_loc3_].setStyle("textSelectedColor",16777215);
  37.          this.mListboxArray[_loc3_].setStyle("defaultIcon","emptyIcon");
  38.          this.mListboxArray[_loc3_].setIconFunction(this.IconManager);
  39.          this.mListboxArray[_loc3_].embedFonts = _global.gUseEmbeddedFont;
  40.          this.mListboxArray[_loc3_].setCellRenderer("HtmlListboxCellRenderer");
  41.          _loc3_ = _loc3_ + 1;
  42.       }
  43.       this.txt_RisultatiVoci.embedFonts = true;
  44.       this.txt_RisultatiContributi.embedFonts = true;
  45.       this.txt_RisultatiProspettive.embedFonts = true;
  46.       this.mResultLabelY = this.txt_RisultatiContributi._y;
  47.       this.SetResultLabelPosAndColor();
  48.       this.searchResultGroup.addEventListener("click",mx.utils.Delegate.create(this,this.onSearchResultViewChange));
  49.       this.mWhiteTextFormat = new TextFormat();
  50.       this.mWhiteTextFormat.color = 16777215;
  51.       this.mBlackTextFormat = new TextFormat();
  52.       this.mBlackTextFormat.color = 3355443;
  53.    }
  54.    function ActiveTab()
  55.    {
  56.       return this.searchResultGroup.selection.data;
  57.    }
  58.    function GetTabList(activeTab)
  59.    {
  60.       if(activeTab == "voci")
  61.       {
  62.          return this.lboxVociSearchResults;
  63.       }
  64.       if(activeTab == "contributi")
  65.       {
  66.          return this.lboxContributiSearchResults;
  67.       }
  68.       if(activeTab == "prospettive")
  69.       {
  70.          return this.lboxProspettiveSearchResults;
  71.       }
  72.       return undefined;
  73.    }
  74.    function GetActiveTabList()
  75.    {
  76.       var _loc2_ = this.ActiveTab();
  77.       return this.GetTabList(_loc2_);
  78.    }
  79.    function SetState(inState)
  80.    {
  81.    }
  82.    function IconManager(itemObj)
  83.    {
  84.       if(itemObj == undefined)
  85.       {
  86.          return undefined;
  87.       }
  88.       switch(itemObj.tipo)
  89.       {
  90.          case "L":
  91.             return "lemmaIcon";
  92.          case "R":
  93.             return "rinvioIcon";
  94.          case "T":
  95.             return "tabIcon";
  96.          case "I":
  97.             return "imageIcon";
  98.          case "F":
  99.             return "imageIcon";
  100.          case "P":
  101.             return "prospettivaIcon";
  102.          default:
  103.             return "emptyIcon";
  104.       }
  105.    }
  106.    function onItemSelected(evtObj)
  107.    {
  108.       var _loc5_ = false;
  109.       var _loc8_ = evtObj.target;
  110.       var _loc7_ = _loc8_.dataProvider.getItemAt(_loc8_.selectedIndex);
  111.       var _loc4_ = _loc7_.data;
  112.       var _loc3_ = _loc7_.tipo;
  113.       var _loc6_ = _loc7_.label;
  114.       if(_loc3_ == "L" || _loc3_ == "R")
  115.       {
  116.          this._parent.gAppendiceSearch.MostraLemma(_loc4_,_loc3_,_loc6_,"ricerca",_loc5_);
  117.       }
  118.       else if(_loc3_ == "I" || _loc3_ == "T" || _loc3_ == "F")
  119.       {
  120.          _root.gAppendiceSearch.MostraContributo(_loc4_,_loc3_,_loc6_,"ricerca",_loc5_);
  121.       }
  122.       else if(_loc3_ == "P")
  123.       {
  124.          _root.gAppendiceSearch.MostraProspettiva(_loc4_,_loc3_,_loc6_,"ricerca",_loc5_);
  125.       }
  126.    }
  127.    function onSearchResultViewChange(evtObj)
  128.    {
  129.       this.mCurrentTab = evtObj.target.selection.data;
  130.       this.lboxVociSearchResults._visible = this.mCurrentTab == "voci";
  131.       this.lboxContributiSearchResults._visible = this.mCurrentTab == "contributi";
  132.       this.lboxProspettiveSearchResults._visible = this.mCurrentTab == "prospettive";
  133.       this.SetResultLabelPosAndColor();
  134.       var _loc2_ = this.GetActiveTabList();
  135.       this.dispatchEvent({type:"resultTabChange",target:this,tab:this.mCurrentTab,itemNum:_loc2_.length});
  136.    }
  137.    function onItemRollOver(evtObj)
  138.    {
  139.       var _loc3_ = evtObj.target;
  140.       var _loc4_ = _loc3_.getItemAt(evtObj.index);
  141.       var _loc2_ = _loc4_.label;
  142.       if(_loc2_)
  143.       {
  144.          this._parent.gTooltipManager.show(_loc2_,null);
  145.       }
  146.    }
  147.    function onItemRollOut(evtObj)
  148.    {
  149.       this._parent.gTooltipManager.hide();
  150.    }
  151.    function onListboxModelChanged(evtObj)
  152.    {
  153.       if(evtObj.eventName == "fetchRows")
  154.       {
  155.          _global.gAlert.ShowAlert("","Caricamento della lista in corso.","EMPTY",10);
  156.       }
  157.       else if(this.mFullyPopulatedCallback == "")
  158.       {
  159.          _global.gAlert.Hide();
  160.       }
  161.       else if(evtObj.eventName == "allRows")
  162.       {
  163.          _global.gAlert.Hide();
  164.          this[this.mFullyPopulatedCallback]();
  165.          this.mFullyPopulatedCallback = "";
  166.       }
  167.    }
  168.    function SetResults(inTab, re)
  169.    {
  170.       var _loc2_ = this.GetTabList(inTab);
  171.       if(_loc2_ && re)
  172.       {
  173.          re.setDeliveryMode("page",_loc2_.rowCount * this.mPagePrefetch,1);
  174.          _loc2_.dataProvider = mx.remoting.RecordSet(re);
  175.          var _loc5_ = this._parent.gAppendiceSearch.GetSearchData();
  176.          if(_loc5_.searchType == "mostra")
  177.          {
  178.             this.SetResultsText(inTab,-1);
  179.          }
  180.          else
  181.          {
  182.             this.SetResultsText(inTab,re.length);
  183.          }
  184.          _loc2_.dataProvider.addEventListener("modelChanged",mx.utils.Delegate.create(this,this.onListboxModelChanged));
  185.          if(inTab == this.ActiveTab())
  186.          {
  187.             this.dispatchEvent({type:"resultTabChange",target:this,tab:this.ActiveTab(),itemNum:re.length});
  188.          }
  189.       }
  190.    }
  191.    function SetResultsText(inTab, inNumItemFound)
  192.    {
  193.       var _loc3_ = "Risultati: " + String(inNumItemFound);
  194.       if(inNumItemFound < 0)
  195.       {
  196.          _loc3_ = "";
  197.       }
  198.       var _loc2_ = undefined;
  199.       if(inTab == "voci")
  200.       {
  201.          _loc2_ = this.txt_RisultatiVoci;
  202.       }
  203.       else if(inTab == "contributi")
  204.       {
  205.          _loc2_ = this.txt_RisultatiContributi;
  206.       }
  207.       else if(inTab == "prospettive")
  208.       {
  209.          _loc2_ = this.txt_RisultatiProspettive;
  210.       }
  211.       if(_loc2_)
  212.       {
  213.          _loc2_.text = _loc3_;
  214.       }
  215.       this.SetResultLabelPosAndColor();
  216.    }
  217.    function clearUI()
  218.    {
  219.       var _loc2_ = 0;
  220.       while(_loc2_ < this.mListboxArray.length)
  221.       {
  222.          this.mListboxArray[_loc2_].dataProvider = [];
  223.          this.mListboxArray[_loc2_].removeAll();
  224.          _loc2_ = _loc2_ + 1;
  225.       }
  226.       this.txt_RisultatiVoci.text = "";
  227.       this.txt_RisultatiContributi.text = "";
  228.       this.txt_RisultatiProspettive.text = "";
  229.    }
  230.    function SetResultLabelPosAndColor()
  231.    {
  232.       this.txt_RisultatiVoci._y = this.mCurrentTab != "voci" ? this.mResultLabelY - 4 : this.mResultLabelY;
  233.       this.txt_RisultatiContributi._y = this.mCurrentTab != "contributi" ? this.mResultLabelY - 4 : this.mResultLabelY;
  234.       this.txt_RisultatiProspettive._y = this.mCurrentTab != "prospettive" ? this.mResultLabelY - 4 : this.mResultLabelY;
  235.       if(this.mCurrentTab == "voci")
  236.       {
  237.          this.txt_RisultatiVoci.setTextFormat(this.mBlackTextFormat);
  238.       }
  239.       else
  240.       {
  241.          this.txt_RisultatiVoci.setTextFormat(this.mWhiteTextFormat);
  242.       }
  243.       if(this.mCurrentTab == "contributi")
  244.       {
  245.          this.txt_RisultatiContributi.setTextFormat(this.mBlackTextFormat);
  246.       }
  247.       else
  248.       {
  249.          this.txt_RisultatiContributi.setTextFormat(this.mWhiteTextFormat);
  250.       }
  251.       if(this.mCurrentTab == "prospettive")
  252.       {
  253.          this.txt_RisultatiProspettive.setTextFormat(this.mBlackTextFormat);
  254.       }
  255.       else
  256.       {
  257.          this.txt_RisultatiProspettive.setTextFormat(this.mWhiteTextFormat);
  258.       }
  259.    }
  260.    function Copy(inWhat)
  261.    {
  262.       var _loc6_ = false;
  263.       var _loc5_ = this.GetActiveTabList();
  264.       var _loc4_ = "";
  265.       var _loc3_ = mx.remoting.RecordSet(_loc5_.dataProvider);
  266.       if(_loc3_.isLocal() || _loc3_.getLocalLength() == _loc3_.getLength())
  267.       {
  268.          var _loc2_ = 0;
  269.          while(_loc2_ < _loc3_.__get__items().length)
  270.          {
  271.             _loc4_ += StringUtils.HtmlToText(StringUtils.HtmlFunction(_loc3_.__get__items()[_loc2_].label)) + "\r";
  272.             _loc2_ = _loc2_ + 1;
  273.          }
  274.       }
  275.       else
  276.       {
  277.          this.mFullyPopulatedCallback = "Copy";
  278.          _loc3_.setDeliveryMode("fetchAll",_loc5_.__get__rowCount() * this.mPagePrefetch,1);
  279.       }
  280.       if(_loc4_ != "")
  281.       {
  282.          System.setClipboard(_loc4_);
  283.       }
  284.       return _loc6_;
  285.    }
  286.    function Print(inWhat)
  287.    {
  288.       var _loc7_ = false;
  289.       var _loc6_ = this.GetActiveTabList();
  290.       var _loc5_ = "";
  291.       var _loc4_ = mx.remoting.RecordSet(_loc6_.dataProvider);
  292.       if(_loc4_.isLocal() || _loc4_.getLocalLength() == _loc4_.getLength())
  293.       {
  294.          var _loc3_ = 0;
  295.          while(_loc3_ < _loc4_.__get__items().length)
  296.          {
  297.             _loc5_ += "<span class=\'rowText\'>" + StringUtils.HtmlFunction(_loc4_.__get__items()[_loc3_].label) + "</span><br>";
  298.             _loc3_ = _loc3_ + 1;
  299.          }
  300.       }
  301.       else
  302.       {
  303.          this.mFullyPopulatedCallback = "Print";
  304.          _loc4_.setDeliveryMode("fetchAll",_loc6_.__get__rowCount() * this.mPagePrefetch,1);
  305.       }
  306.       if(_loc5_ != "" && _global.gPrint)
  307.       {
  308.          _global.gPrint.PrintHtml("",_loc5_);
  309.       }
  310.       return _loc7_;
  311.    }
  312.    function Save(inWhat)
  313.    {
  314.       var _loc8_ = false;
  315.       var _loc7_ = this.GetActiveTabList();
  316.       var _loc6_ = "";
  317.       var _loc5_ = mx.remoting.RecordSet(_loc7_.dataProvider);
  318.       if(_loc5_.isLocal() || _loc5_.getLocalLength() == _loc5_.getLength())
  319.       {
  320.          var _loc4_ = 0;
  321.          while(_loc4_ < _loc5_.__get__items().length)
  322.          {
  323.             _loc6_ += "<span class=\'rowText\'>" + StringUtils.HtmlFunction(_loc5_.__get__items()[_loc4_].label) + "</span><br>";
  324.             _loc4_ = _loc4_ + 1;
  325.          }
  326.       }
  327.       else
  328.       {
  329.          this.mFullyPopulatedCallback = "Save";
  330.          _loc5_.setDeliveryMode("fetchAll",_loc7_.__get__rowCount() * this.mPagePrefetch,1);
  331.       }
  332.       if(_loc6_ != "" && _root.gAppendiceSearch)
  333.       {
  334.          var _loc9_ = _global.gStyleManager.CSStoHTML(_global.gStyleManager.GetCSS());
  335.          _root.gAppendiceSearch.ExportHtmlFile("Risultato della Ricerca",_loc9_,"",_loc6_);
  336.       }
  337.       return _loc8_;
  338.    }
  339. }
  340.